package net.siufung.core.exception;

import lombok.EqualsAndHashCode;
import net.siufung.core.result.IResultType;
import net.siufung.core.result.ResultFail;

/**
 *
 * @see BizServiceException
 * 全局异常
 * @author 陈建峰
 * @since 2022/4/26 10:32 上午
 */
@Deprecated
@EqualsAndHashCode(callSuper = true)
public class SiufungServiceException extends RuntimeException {

    private static final long serialVersionUID = -1703213228643457435L;

    /**
     * 参数只有消息的构造
     * @param message 消息
     */
    public SiufungServiceException(String message) {
        this(ResultFail.ERROR.getCode(), message);
    }

    /**
     * 参数是结果类型结构的构造
     * @param resultType 结果类型
     */
    public SiufungServiceException(IResultType resultType) {
        this(resultType.getCode(), resultType.getMessage());
    }

    /**
     * 参数是编码和消息的构造
     * @param code 消息编码
     * @param message 消息
     */
    public SiufungServiceException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
        super.fillInStackTrace();
    }

    private final Integer code;
    private final String message;
}
